package com.lzy.cloud.mq.service;

import com.lzy.cloud.mq.remote.dtos.MsgOrderRefundDto;
import com.lzy.cloud.mq.remote.dtos.PayBackDTO;
import lombok.extern.java.Log;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.lzy.cloud.mq.config.ConfigMq.PAYMENT_ROUTING_KEY;
import static com.lzy.cloud.mq.config.ConfigMq.UNSUBSCRIBE_ROUTING_KEY;

@Component
@Log
public class PaymentSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public Object sender(PayBackDTO payBackDTO){

        log.info("payment.processing send message: 支付回调业务处理发送");
        Object obj = rabbitTemplate.convertSendAndReceive(PAYMENT_ROUTING_KEY, payBackDTO);
        return obj;
    }

    public Object unsubscribeSender(MsgOrderRefundDto msgOrderRefundDto){
        log.info("unsubscribe send message: 退订退款业务处理发送");
        Object obj = rabbitTemplate.convertSendAndReceive(UNSUBSCRIBE_ROUTING_KEY,msgOrderRefundDto);
        return obj;
    }

}
